home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_400 / 428_02 / libsrc / pushstat.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-03-13  |  1.1 KB  |  53 lines

  1. /*
  2. ** pushstat.c
  3. **
  4. ** Pictor, Version 1.51, Copyright (c) 1992-94 SoftCircuits
  5. ** Redistributed by permission.
  6. */
  7.  
  8. #include <stdio.h>
  9. #include <stdlib.h>
  10. #include "pictor.h"
  11.  
  12. #define STACK_SIZE   10
  13. static int *stack[STACK_SIZE];
  14. static int stackptr = 0;
  15.  
  16. /*
  17. ** Saves the contents of the status bar so that it can later be
  18. ** restored with popstatus. The status bar is then cleared.
  19. ** Returns TRUE if successful, FALSE if stack is full.
  20. */
  21. int pushstatus(void)
  22. {
  23.     if(stackptr < STACK_SIZE) {
  24.         stack[stackptr] = malloc(_PL_columns * sizeof(int));
  25.         if(stack[stackptr] != NULL)
  26.             getscrn(stack[stackptr],_PL_statusrow,1,1,_PL_columns);
  27.         clrstatus();
  28.         stackptr++;
  29.         return(TRUE);
  30.     }
  31.     return(FALSE);
  32.  
  33. } /* pushstatus */
  34.  
  35. /*
  36. ** Restores the status bar to what it was the last time pushstatus
  37. ** was called. Returns TRUE if successful, FALSE if stack was empty.
  38. */
  39. int popstatus(void)
  40. {
  41.     if(stackptr > 0) {
  42.         stackptr--;
  43.         if(stack[stackptr] != NULL) {
  44.             putscrn(stack[stackptr],_PL_statusrow,1,1,_PL_columns);
  45.             free(stack[stackptr]);
  46.         }
  47.         else clrstatus();
  48.         return(TRUE);
  49.     }
  50.     return(FALSE);
  51.  
  52. } /* popstatus */
  53.